home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-02-26 | 3.7 KB | 181 lines | [TEXT/CWIE] |
- unit MyLowLevel;
-
- interface
-
- uses
- Types;
-
- (* Global Bashing - Get constants from SysEqu.p *)
-
- {$definec GetGlobalB(addr) Ptr(ad)^}
- {$definec SetGlobalB(addr, n) Ptr(ad)^ := n}
- {$definec GetGlobalW(ad) IntegerPtr(ad)^}
- {$definec SetGlobalW(ad, n) IntegerPtr(ad)^ := n}
- {$definec GetGlobalL(ad) LongIntPtr(ad)^}
- {$definec SetGlobalL(ad, n) LongIntPtr(ad)^ := n}
-
- function GetGlobalS (ad: univ longint): Str255;
- procedure SetGlobalS (ad: univ longint; s: Str255); { only bashes len+1 chars }
-
- {$definec AddPtrLong( p, offset ) Ptr(ord4(p) + offset)}
- {$definec OffsetPtr( p, offset ) Ptr(p) := Ptr(ord4(p) + (offset))}
- {$definec SubPtrPtr( left, right ) (ord4(left) - ord4(right))}
- {$definec GetUnsignedByte( p, offset ) (AddPtrLong(p, offset)^ and $00FF)}
- {$definec SetUnsignedByte( p, offset, value ) (AddPtrLong(p, offset)^ := band(value, $00FF)}
- {$definec CompLS( a1, a2 ) (unsignedlong(a1) <= unsignedlong(a2))}
- {$definec CompLO( a1, a2 ) (unsignedlong(a1) < unsignedlong(a2))}
- {$definec CompHS( a1, a2 ) (unsignedlong(a1) >= unsignedlong(a2))}
- {$definec CompHI( a1, a2 ) (unsignedlong(a1) > unsignedlong(a2))}
-
- procedure BSETW (var l: integer; num: integer);
- procedure BCLRW (var l: integer; num: integer);
-
- (* Register Getting - Address *)
-
- {$IFC not GENERATINGPOWERPC}
- function GetRegA0: Ptr;
- inline
- $2E88; (* movea.l a0,(sp) ; fetch a0 into tos *)
- function GetRegA1: Ptr;
- inline
- $2E89;
- function GetRegA2: Ptr;
- inline
- $2E8A;
- function GetRegA3: Ptr;
- inline
- $2E8B;
- function GetRegA4: Ptr;
- inline
- $2E8C;
- function GetRegA5: Ptr;
- inline
- $2E8D;
- function GetRegA6: Ptr;
- inline
- $2E8E;
- function GetRegA7: Ptr;
- inline
- $2E8F;
-
- (* Register Setting - Address *)
-
- procedure SetRegA0 (n: univ Ptr);
- inline
- $205F; (* movea.l (sp)+,a0 ; pop n into a0 *)
- procedure SetRegA1 (n: univ Ptr);
- inline
- $225F;
- procedure SetRegA2 (n: univ Ptr);
- inline
- $245F;
- procedure SetRegA3 (n: univ Ptr);
- inline
- $265F;
- procedure SetRegA4 (n: univ Ptr);
- inline
- $285F;
- procedure SetRegA5 (n: univ Ptr);
- inline
- $2A5F;
- procedure SetRegA6 (n: univ Ptr);
- inline
- $2C5F;
- procedure SetRegA7 (n: univ Ptr);
- inline
- $2E5F;
-
- (* Register Getting - Data *)
-
- function GetRegD0: longint;
- inline
- $2E80; (* move.l d0,(sp) ; fetch d0 into tos *)
- function GetRegD1: longint;
- inline
- $2E81;
- function GetRegD2: longint;
- inline
- $2E82;
- function GetRegD3: longint;
- inline
- $2E83;
- function GetRegD4: longint;
- inline
- $2E84;
- function GetRegD5: longint;
- inline
- $2E85;
- function GetRegD6: longint;
- inline
- $2E86;
- function GetRegD7: longint;
- inline
- $2E87;
-
- (* Register Setting - Data *)
-
- procedure SetRegD0 (n: univ longint);
- inline
- $201F; (* move.l (sp)+,(d0) ; pop n into d0 *)
- procedure SetRegD1 (n: univ longint);
- inline
- $221F;
- procedure SetRegD2 (n: univ longint);
- inline
- $241F;
- procedure SetRegD3 (n: univ longint);
- inline
- $261F;
- procedure SetRegD4 (n: univ longint);
- inline
- $281F;
- procedure SetRegD5 (n: univ longint);
- inline
- $2A1F;
- procedure SetRegD6 (n: univ longint);
- inline
- $2C1F;
- procedure SetRegD7 (n: univ longint);
- inline
- $2E1F;
- {$ENDC}
-
- implementation
-
- uses
- Memory;
-
- function GetGlobalS (ad: univ longint): Str255;
- var
- tmp: Str255;
- begin
- BlockMoveData(pointer(ad), @tmp, sizeof(tmp));
- GetGlobalS := tmp;
- end; (* GetGlobalB *)
-
- procedure SetGlobalS (ad: univ longint; s: Str255); (* only bashes}
- {len+1 chars *)
- begin
- BlockMoveData(@s, pointer(ad), Length(s) + 1);
- end; (* GetGlobalB *)
-
- procedure BSETW (var l: integer; num: integer);
- var
- ll: longint;
- begin
- ll := l;
- BSET(ll, num);
- l := ll;
- end;
-
- procedure BCLRW (var l: integer; num: integer);
- var
- ll: longint;
- begin
- ll := l;
- BCLR(ll, num);
- l := ll;
- end;
-
- end.
-